<template>
  <div class="container">
    <div class="top-block">
      <div class="item-info">
        <div class="item-icon">
          <img :src="goodInfo.img" alt="" />
          <!-- <div class="item-number">共1件商品</div> -->
        </div>
        <div class="item-detail">
          <div class="title">{{ goodInfo.name }}</div>
          <div class="order_number">物流编号：{{ detail.number }}</div>
        </div>
      </div>
      <div class="express-status">
        <div class="check-point" style="transform:translate(105%,0.5rem);">
          <div class="status spc">
            已发货
          </div>
          <div class="dot active"></div>
          <div class="name"></div>
        </div>
        <div
          class="connect-icon "
          :class="{ active: detail.deliverystatus >= 1 }"
          style="transform:translate(90%,1.6rem);"
        ></div>
        <div class="check-point" style="transform:translate(425%,0.5rem);">
          <div class="status">
            运输中
          </div>
          <div
            class="dot"
            :class="{ active: detail.deliverystatus >= 1 }"
          ></div>
        </div>
        <div
          class="connect-icon"
          :class="{ active: detail.deliverystatus >= 2 }"
          style="transform:translate(220%,1.6rem);"
        ></div>
        <div class="check-point" style="transform:translate(725%,0.5rem);">
          <div class="status">
            派件中
          </div>
          <div
            class="dot"
            :class="{ active: detail.deliverystatus >= 2 }"
          ></div>
        </div>
        <div
          class="connect-icon"
          :class="{ active: detail.deliverystatus >= 3 }"
          style="transform:translate(350%,1.6rem);"
        ></div>
        <div class="check-point" style="transform:translate(1425%,1.4rem);">
          <div
            class="dot"
            :class="{ active: detail.deliverystatus >= 3 }"
          ></div>
          <div class="name ">到达</div>
        </div>
      </div>
    </div>
    <div v-if="detail.list" class="express-detail">
      <div
        v-for="(item, index) in detail.list"
        :key="index"
        class="detail-cell"
      >
        <div class="time">
          <div class="tiny">{{ item.time.split(" ")[1] }}</div>
          <div class="date">{{ item.time.split(" ")[0] }}</div>
        </div>
        <div class="info">{{ item.status }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import { getExpressTrackDetail } from "@/api/mall";
export default {
  data() {
    return {
      detail: {},
      goodInfo: {}
    };
  },
  created() {
    getExpressTrackDetail({ id: this.$route.query.id }).then(res => {
      if (res.status === 200) {
        this.detail = res.data.data.result;
        this.goodInfo = res.data.data.info;
      }
    });
  }
};
</script>

<style lang="less" scoped>
.container {
  min-height: 100%;
  height: auto;
  .top-block {
    position: -webkit-sticky; /* safari 浏览器 */
    position: sticky; /* 其他浏览器 */
    top: 0;
  }
  .item-info {
    height: 3.6rem;
    background: #0078ff;
    display: flex;
    padding: 0.45rem 8%;
    box-sizing: border-box;

    .item-icon {
      position: relative;
      width: 2.8rem;
      height: 2.8rem;
      margin-right: 0.48rem;
      background-color: #dfdfdf;
      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
      .item-number {
        line-height: 1rem;
        width: 100%;
        position: absolute;
        color: #fff;
        text-align: center;
        font-size: 0.44rem;
        background: rgba(0, 0, 0, 0.5);
        left: 0;
        bottom: 0;
      }
    }

    .item-detail {
      width: calc(100% - 3.28rem);
      position: relative;

      .title {
        font-size: 0.56rem;
        color: #fff;
      }

      .order_number {
        position: absolute;
        bottom: 0;
        left: 0;
        color: #fff;
        font-size: 0.48rem;
      }
    }
  }

  .express-status {
    height: 3rem;
    background: #fff;
    text-align: center;
    position: relative;

    .connect-icon {
      position: absolute;
      left: 0;
      top: 0;
      height: 0.04rem;
      background: rgba(233, 233, 233, 1);
      width: 18.6%;
    }

    .check-point {
      // width: 2.5625rem;
      position: absolute;
      left: 0;
      top: 0;

      .status {
        font-size: 0.4rem;
        height: 0.7rem;
        // width: 1.5rem;
        white-space: nowrap;
        line-height: 0.7rem;
        color: #444444;
        margin-bottom: 0.15rem;
        text-align: center;
      }

      .dot {
        background: rgba(233, 233, 233, 1);
        border-radius: 50%;
        height: 0.4rem;
        width: 0.4rem;
        margin: 0 auto;
      }

      .spc {
        color: #fff;
        background-color: #f85859;
        border-radius: 0.24rem;
        font-size: 0.4rem;
      }

      .name {
        white-space: nowrap;
        font-size: 0.44rem;
        font-family: "PingFang-SC-Medium";
        font-weight: 500;
        color: rgba(68, 68, 68, 1);
        margin-top: 0.15rem;
      }
    }

    .active {
      background: rgba(248, 88, 89, 1) !important;
    }
  }

  .express-detail {
    background-color: #fff;
    margin-top: 0.48rem;
    padding: 0 3.2%;

    .detail-cell {
      height: 2rem;
      display: flex;
      width: 100%;
      align-items: center;
      .time {
        text-align: center;
        font-size: 0.4rem;
        width: 2.5rem;
        .tiny {
          // margin-top: 0.6rem;
          color: rgba(68, 68, 68, 1);
        }

        .date {
          margin-top: 0.2rem;
          color: rgba(153, 153, 153, 1);
        }
      }

      .info {
        // line-height: 2rem;
        width: calc(100% - 2.5rem);
        margin-left: 0.48rem;
        font-size: 0.48rem;
        font-family: "PingFang-SC-Medium";
        font-weight: 500;
        color: rgba(68, 68, 68, 1);
        max-height: 2rem;
        overflow: hidden;
      }
    }
  }
}
</style>
